import 'dart:async';
import 'dart:math';

import 'package:bloc/bloc.dart';
import 'package:equatable/equatable.dart';

part 'index_count_event.dart';
part 'index_count_state.dart';

class IndexCountBloc extends Bloc<IndexCountEvent, IndexCountState> {
  int current;

  IndexCountBloc() : super(IndexCountInitial(0));

  @override
  Stream<IndexCountState> mapEventToState(
    IndexCountEvent event,
  ) async* {
    if (event is SetIndexCountEvent) {
      yield* _setMapEventToState(event);
    }
  }

  Stream<IndexCountState> _setMapEventToState(SetIndexCountEvent event) async* {
    this.current = event.current;
    yield IndexCountChange(this.current);
  }
}
